<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<link href="${pageContext.request.contextPath}/css/style.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/table.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/dwz/themes/default/style.css" rel="stylesheet" type="text/css" media="screen" />
<link href="${pageContext.request.contextPath}/dwz/themes/css/core.css" rel="stylesheet" type="text/css" media="screen" />
<script src="${pageContext.request.contextPath}/jquery/jquery-2.1.4.min.js"></script>
<script>
	function deletePermission() {
		let zTreeObj = parent.treeFrame.$.fn.zTree.getZTreeObj("permission_tree");
		let selectedNode = zTreeObj.getSelectedNodes()[0];
		var json = {"id":selectedNode.id};



		$.post("${pageContext.request.contextPath}/permission?method=deletePermissionById",json,function (result) {
			if (result.code == "200"){
				//从树中删除选中的当前节点
				zTreeObj.removeNode(selectedNode);
				//获取父节点数据对象
				let parentNode = zTreeObj.getNodeByParam("id", selectedNode.pid, null);
				//选中父节点
				zTreeObj.selectNode(parentNode);

				location.href =  "permission?method=getPermissionById&id="+parentNode.id;

			}
		},"json")
	}
</script>
<input type="text" hidden  id="typeJsp">
<table border="0" cellpadding="0" cellspacing="0" class="table_border">
	<tr>
		<td>
			<table width="100%" border="0" cellpadding="0" cellspacing="0"
				class="table_padding">
				<tr>
					<td><font style="font-size: 12px; color: red;"><strong>提示：点击左边树上的节点查看许可详情</strong></font>
					</td>
					<td width="25" height="26" align="right"></td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" class="table_border">
	<tr>
		<td>
			<table width="100%" border="0" cellpadding="0" cellspacing="0"
				class="table_right">
				<tr>
					<td><font style="font-size: 12px;"><strong>许可详细信息</strong></font>
					</td>
					<td width="25" height="26" align="left"></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="100%" border="0" cellspacing="0" class="table_right">
				<tr>
					<td align="center">
						<table border="0" cellpadding="0" cellspacing="0"
							class="box_table" id="box_table2">
							<thead>
								<tr>
									<td>名称：</td>
									<td>${permission.name}</td>
								</tr>
								<tr>
									<td>模块URL：</td>
									<td>${permission.moduleUrl}</td>
								</tr>
								<tr>
									<td>操作URL：</td>
									<td>
										${permission.operationUrl}</td>
								</tr>
								<tr>
									<td>排序号：</td>
									<td>${permission.orderNo}</td>
								</tr>
							</thead>
							<tbody>
							</tbody>
						</table>
						<table border="0" cellpadding="0" cellspacing="0"
							class="operation">
							<thead>
								<tr>
									<td height="24">&nbsp;</td>
								</tr>
							</thead>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="100%" border="0" cellpadding="0" cellspacing="0"
				class="table_padding">
				<tr>
					<td height="21" align="right">
						<table align="left">
							<tr>
								<td width="50px" id="addBtn">
									<a class="button"
									   href="permission?method=getAddPermission&pid=${permission.id}">
										<span>新增</span>
									</a>
								</td>
								<td width="50px" id="delBtn"><a class="button"
									href="javascript:void(0);" onclick="deletePermission()"><span>删除</span></a></td>
								<td width="50px" id="updateBtn">
									<a class="button" href="permission?method=getUpdatePermission&id=${permission.id}">
										<span>修改</span>
									</a>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<script>
	$(function () {
		let permission = '${permissionAll}';
		if (permission.indexOf("permission?method=getAddPermission")<0){
			$("#addBtn").hide();
		}
		if (permission.indexOf("permission?method=getUpdatePermission")<0){
			$("#updateBtn").hide();
		}
		if (permission.indexOf("permission?method=deletePermissionById")<0){
			$("#delBtn").hide();
		}

	})
</script>
